package com.gaswell.aop.source;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @ClassName AspectTest
 * @Author xiaow
 * @DATE 2024/4/14 12:40
 **/
@Aspect
public class AspectTest {

    @Pointcut("execution(* *.study(..))")
    public void test(){}

    @Before("test()")
    public void before(){
        System.out.println("before study:打开课本");
    }

    @After("test()")
    public void after(){
        System.out.println("after study:合上课本");
    }

    @Around("test()")
    public Object around(ProceedingJoinPoint p){
        System.out.println("环绕通知  before study:打开课本");
        Object o = null;
        try {
            o = p.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        System.out.println("环绕通知  after study:合上课本");
        return o;
    }
}